﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class Indexableinsertsturningtoolforexternalthreading
    {
        public static void _Indexableinsertsturningtoolforexternalthreading(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            double scale = 3; //放大系数

            double h = 20;
            double b = 20;
            double dconms = 20;
            double l3 = 16.5;
            double wta = 9.32;
            double wf = 15;
            double oal = 125;
            double s = 3;



            //坐标
            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X + oal + 6, v1.Y);
            Vector2 v3 = new Vector2(v1.X + 3, v1.Y);
            Vector2 v4 = new Vector2(v3.X, v3.Y + dconms / 2);
            Vector2 v5 = new Vector2(v4.X + oal / 1.4, v4.Y);
            Vector2 v7 = new Vector2(v3.X + oal, v3.Y);
            Vector2 v6 = new Vector2(v7.X - l3, v7.Y);
            Vector2 v8 = new Vector2(v7.X, v7.Y - s);
            Vector2 v9 = new Vector2(v8.X - l3 / 4.232, v8.Y);
            Vector2 v10 = new Vector2(v9.X - 0.3, v3.Y - dconms / 3.782);
            Vector2 v11 = new Vector2(v10.X - oal / 35.41, v4.Y - dconms);
            Vector2 v12 = new Vector2(v4.X, v11.Y);
            Vector2 v13 = new Vector2(v9.X, v7.Y);
            Vector2 v14 = new Vector2(v6.X + l3 / 4.773, v6.Y);
            Vector2 v15 = new Vector2(v14.X, v8.Y);
            Vector2 v16 = new Vector2(v6.X, v8.Y);
            Vector2 v17 = new Vector2(v6.X + l3 / 12, v6.Y);
            Vector2 v18 = new Vector2(v17.X, v8.Y);
            Vector2 a1 = new Vector2(v7.X - oal / 2.233, v7.Y);
            Vector2 a2 = new Vector2(v7.X - l3 / 2, v7.Y);

            Vector2 v19 = new Vector2(v1.X, v1.Y - oal);
            Vector2 v20 = new Vector2(v19.X + oal + 6, v19.Y);
            Vector2 v45 = new Vector2(v19.X + 3, v19.Y);
            Vector2 v21 = new Vector2(v45.X, v45.Y + dconms / 2);
            Vector2 v22 = new Vector2(v11.X, v21.Y);
            Vector2 v23 = new Vector2(v9.X, v22.Y - dconms / 3.963);
            Vector2 v24 = new Vector2(v45.X + oal, v45.Y - wta);
            Vector2 v25 = fun.Polar(v24, 155 * pi / 180, l3 / 9.156);
            Vector2 v26 = fun.Polar(v25, 89 * pi / 180, l3 / 8.766);
            Vector2 v27 = fun.Polar(v26, 120 * pi / 180, l3 / 1.702);
            Vector2 v28 = fun.Polar(v27, -176 * pi / 180, l3 / 13.733);
            Vector2 v29 = fun.Polar(v28, 135 * pi / 180, l3 / 10.564);
            Vector2 v30 = fun.Polar(v29, -108 * pi / 180, l3 / 7.103);
            Vector2 v31 = fun.Polar(v30, -145 * pi / 180, l3 / 7.774); ;
            Vector2 v32 = fun.Polar(v31, -123 * pi / 180, l3 / 1.682);
            Vector2 v33 = fun.Polar(v32, -42 * pi / 180, l3 / 16.48);
            Vector2 v34 = fun.Polar(v33, -93 * pi / 180, l3 / 7.63);
            Vector2 v35 = fun.Polar(v34, 21 * pi / 180, l3 / 6.438);
            Vector2 v38 = fun.Polar(v24, -132 * pi / 180, l3 / 8.078);
            Vector2 v37 = fun.Polar(v38, -116 * pi / 180, l3 / 15.259);
            Vector2 v36 = new Vector2(v37.X - l3 / 1.731, v37.Y);
            Vector2 v39 = fun.Polar(v24, -60 * pi / 180, (v24.Y - v37.Y) / Math.Cos(30 * pi / 180));
            Vector2 v40 = new Vector2(v21.X, v21.Y - dconms);
            Vector2 v41 = new Vector2(v33.X - (v33.Y - v40.Y) * Math.Tan(3 * pi / 180), v40.Y);
            Vector2 v42 = fun.Polar(v41, 162 * pi / 180, oal / 6.779);
            Vector2 v43 = fun.Polar(v42, 81 * pi / 180, oal / 12.267);
            Vector2 v44 = new Vector2(v22.X - oal / 15.152, v22.Y);
            Vector2 v46 = new Vector2(v23.X, v26.Y + (v26.X - v23.X) / Math.Tan(30 * pi / 180));
            Vector2 v47 = new Vector2(v32.X + l3 / 1.962, v36.Y + l3 / 2.986);
            Vector2 a3 = new Vector2(v1.X, v20.Y);

            Vector2 v48 = new Vector2(v2.X + oal, v5.Y);
            Vector2 v49 = new Vector2(v48.X + oal, v48.Y);
            Vector2 v50 = new Vector2(v49.X, v49.Y - s);
            Vector2 v51 = new Vector2(v50.X - l3 / 4.232, v50.Y);
            Vector2 v52 = new Vector2(v51.X, v49.Y - h);
            Vector2 v53 = new Vector2(v48.X, v52.Y);
            Vector2 v54 = new Vector2(v51.X, v49.Y);
            Vector2 v55 = new Vector2(v49.X - l3, v49.Y);
            Vector2 v56 = new Vector2(v55.X, v50.Y);
            Vector2 v57 = new Vector2(v55.X + l3 / 12, v55.Y);
            Vector2 v58 = new Vector2(v57.X, v50.Y);
            Vector2 v59 = new Vector2(v55.X + l3 / 4.773, v55.Y);
            Vector2 v60 = new Vector2(v59.X, v50.Y);
            Vector2 v61 = new Vector2(v48.X + oal / 1.353, v48.Y);
            Vector2 v62 = new Vector2(v61.X, v53.Y);
            Vector2 a4 = new Vector2(v49.X - oal / 2.233, v49.Y);
            Vector2 a5 = new Vector2(v49.X - l3 / 2, v49.Y);

            Vector2 v63 = new Vector2(v48.X, v48.Y - oal);
            Vector2 v64 = new Vector2(v63.X + oal / 1.107, v63.Y);
            Vector2 v65 = new Vector2(v52.X, v64.Y - b / 3.818);
            Vector2 v66 = new Vector2(v63.X + oal, v64.Y - b / 2 - wta);
            Vector2 v85 = fun.Polar(v66, 155 * pi / 180, l3 / 9.156);
            Vector2 v67 = fun.Polar(v85, 89 * pi / 180, l3 / 8.766);
            Vector2 v68 = fun.Polar(v67, 120 * pi / 180, l3 / 1.702);
            Vector2 v69 = fun.Polar(v68, -176 * pi / 180, l3 / 13.733);
            Vector2 v70 = fun.Polar(v69, 135 * pi / 180, l3 / 10.564);
            Vector2 v71 = fun.Polar(v70, -108 * pi / 180, l3 / 7.103);
            Vector2 v72 = fun.Polar(v71, -145 * pi / 180, l3 / 7.774);
            Vector2 v73 = fun.Polar(v72, -123 * pi / 180, l3 / 1.682);
            Vector2 v74 = fun.Polar(v73, -42 * pi / 180, l3 / 16.48);
            Vector2 v75 = fun.Polar(v74, -93 * pi / 180, l3 / 7.63);
            Vector2 v76 = fun.Polar(v75, 21 * pi / 180, l3 / 6.438);
            Vector2 v79 = fun.Polar(v66, -132 * pi / 180, l3 / 8.078);
            Vector2 v78 = fun.Polar(v79, -116 * pi / 180, l3 / 15.259);
            Vector2 v77 = new Vector2(v78.X - l3 / 1.731, v78.Y);
            Vector2 v80 = fun.Polar(v66, -60 * pi / 180, (v66.Y - v78.Y) / Math.Cos(30 * pi / 180));
            Vector2 v81 = new Vector2(v63.X, v63.Y - b);
            Vector2 v82 = new Vector2(v62.X, v81.Y);
            Vector2 v83 = new Vector2(v82.X, v82.Y -1);
            Vector2 v84 = new Vector2(v65.X, v67.Y + (v67.X - v65.X) / Math.Tan(30 * pi / 180));
            Vector2 v86= new Vector2(v73.X + l3 / 1.962, v77.Y + l3 / 2.986);
            Vector2 v87 = new Vector2(v74.X + (v74.Y - v83.Y) * Math.Tan(3 * pi / 180), v83.Y);
            Vector2 a6 = new Vector2(v4.X, v64.Y - b / 2);
            Vector2 a7 = new Vector2(v65.X, a6.Y);

            Vector2 v88 = new Vector2(v5.X, v39.Y - oal);
            Vector2 v89 = fun.Polar(v88, 120 * pi / 180, oal / 2.201);
            Vector2 v90 = fun.Polar(v89, -124 * pi / 180, oal / 7.76);
            Vector2 v91 = fun.Polar(v90, -108 * pi / 180, oal / 15.971);
            Vector2 v92 = fun.Polar(v91, -105 * pi / 180, oal / 14.769);
            Vector2 v93 = fun.Polar(v92, -109 * pi / 180, oal / 17.386);
            Vector2 v94 = fun.Polar(v93, -93 * pi / 180, oal / 18.313);
            Vector2 v95 = new Vector2(v88.X - oal / 2.693, v88.Y);
            Vector2 v96 = new Vector2(v88.X - oal / 4.15, v88.Y);
            Vector2 v97 = fun.Polar(v96, 28 * pi / 180, oal / 9.953);
            Vector2 v98 = fun.Polar(v97, 43 * pi / 180, oal / 83.242);
            Vector2 v99 = fun.Polar(v98, 121 * pi / 180, oal / 72.29);
            Vector2 v100 = fun.Polar(v99, 158 * pi / 180, oal / 10.405);
            Vector2 v101 = fun.Polar(v100, 90 * pi / 180, oal / 24.748);
            Vector2 v102 = fun.Polar(v101, 30 * pi / 180, oal / 34.772);
            Vector2 v103 = new Vector2(v102.X, v88.Y + (v88.X - v102.X) * Math.Tan(60 * pi / 180));
            Vector2 v104 = new Vector2(v88.X + oal / 3.375, v88.Y + oal / 2.075);
            Vector2 v105 = new Vector2(v104.X - oal, v104.Y);
            Vector2 v106 = new Vector2(v105.X, v105.Y - oal / 1.451);
            Vector2 v107 = new Vector2(v104.X, v106.Y);

            Vector2 a88 = new Vector2(v62.X, v80.Y - oal);
            Vector2 a89 = fun.Polar(a88, 120 * pi / 180, oal / 2.201);
            Vector2 a90 = fun.Polar(a89, -124 * pi / 180, oal / 7.76);
            Vector2 a91 = fun.Polar(a90, -108 * pi / 180, oal / 15.971);
            Vector2 a92 = fun.Polar(a91, -105 * pi / 180, oal / 14.769);
            Vector2 a93 = fun.Polar(a92, -109 * pi / 180, oal / 17.386);
            Vector2 a94 = fun.Polar(a93, -93 * pi / 180, oal / 18.313);
            Vector2 a95 = new Vector2(a88.X - oal / 2.693, a88.Y);
            Vector2 a96 = new Vector2(a88.X - oal / 4.15, a88.Y);
            Vector2 a97 = fun.Polar(a96, 28 * pi / 180, oal / 9.953);
            Vector2 a98 = fun.Polar(a97, 43 * pi / 180, oal / 83.242);
            Vector2 a99 = fun.Polar(a98, 121 * pi / 180, oal / 72.29);
            Vector2 a100 = fun.Polar(a99, 158 * pi / 180, oal / 10.405);
            Vector2 a101 = fun.Polar(a100, 90 * pi / 180, oal / 24.748);
            Vector2 a102 = fun.Polar(a101, 30 * pi / 180, oal / 34.772);
            Vector2 a103 = new Vector2(a102.X, a88.Y + (a88.X - a102.X) * Math.Tan(60 * pi / 180));
            Vector2 a104 = new Vector2(a88.X + oal / 3.375, a88.Y + oal / 2.075);
            Vector2 a105 = new Vector2(a104.X - oal, a104.Y);
            Vector2 a106 = new Vector2(a105.X, a105.Y - oal / 1.451);
            Vector2 a107 = new Vector2(a104.X, a106.Y);






            //作图
            Line line1 = new Line(v1, v2);
            line1.Layer = centre;
            line1.Linetype = Linetype.DashDot;
            line1.LinetypeScale = 3;
            dxf.AddEntity(line1);

            LwPolyline line2 = new LwPolyline();
            line2.Vertexes.Add(new LwPolylineVertex(v5));
            line2.Vertexes.Add(new LwPolylineVertex(v4));
            line2.Vertexes.Add(new LwPolylineVertex(v12));
            line2.Vertexes.Add(new LwPolylineVertex(v11));
            line2.Vertexes.Add(new LwPolylineVertex(v10));
            line2.Vertexes.Add(new LwPolylineVertex(v9));
            line2.Vertexes.Add(new LwPolylineVertex(v13));
            line2.Vertexes.Add(new LwPolylineVertex(v7));
            line2.Vertexes.Add(new LwPolylineVertex(v8));
            line2.Vertexes.Add(new LwPolylineVertex(v16));
            line2.Vertexes.Add(new LwPolylineVertex(v6));
            line2.Vertexes.Add(new LwPolylineVertex(v13));
            fun.PolyFill(dxf, line2, 0.5, contour);

            LwPolyline line3 = new LwPolyline();
            line3.Vertexes.Add(new LwPolylineVertex(v5));
            line3.Vertexes.Add(new LwPolylineVertex(v6));
            line3.Vertexes.Add(new LwPolylineVertex(v17));
            line3.Vertexes.Add(new LwPolylineVertex(v18));
            line3.Vertexes.Add(new LwPolylineVertex(v15));
            line3.Vertexes.Add(new LwPolylineVertex(v14));
            line3.Vertexes[0].Bulge = Math.Tan(61 * pi / 180 / 4);
            fun.PolyFill(dxf, line3, 0.5, contour);


            //2
            Line line4 = new Line(v19, v20);
            line4.Layer = centre;
            line4.Linetype = Linetype.DashDot;
            line4.LinetypeScale = 3;
            dxf.AddEntity(line4);

            LwPolyline line5 = new LwPolyline();
            line5.Vertexes.Add(new LwPolylineVertex(v46));
            line5.Vertexes.Add(new LwPolylineVertex(v23));
            line5.Vertexes.Add(new LwPolylineVertex(v22));
            line5.Vertexes.Add(new LwPolylineVertex(v21));
            line5.Vertexes.Add(new LwPolylineVertex(v40));
            line5.Vertexes.Add(new LwPolylineVertex(v41));
            line5.Vertexes.Add(new LwPolylineVertex(v42));
            line5.Vertexes.Add(new LwPolylineVertex(v43));
            line5.Vertexes.Add(new LwPolylineVertex(v44));
            line5.Vertexes[5].Bulge = Math.Tan(-32 * pi / 180 / 4);
            line5.Vertexes[6].Bulge = Math.Tan(-120 * pi / 180 / 4);
            line5.Vertexes[7].Bulge = Math.Tan(-11 * pi / 180 / 4);
            fun.PolyFill(dxf, line5, 0.5, contour);

            LwPolyline line6 = new LwPolyline();
            line6.Vertexes.Add(new LwPolylineVertex(v24));
            line6.Vertexes.Add(new LwPolylineVertex(v25));
            line6.Vertexes.Add(new LwPolylineVertex(v26));
            line6.Vertexes.Add(new LwPolylineVertex(v27));
            line6.Vertexes.Add(new LwPolylineVertex(v28));
            line6.Vertexes.Add(new LwPolylineVertex(v29));
            line6.Vertexes.Add(new LwPolylineVertex(v30));
            line6.Vertexes.Add(new LwPolylineVertex(v31));
            line6.Vertexes.Add(new LwPolylineVertex(v32));
            line6.Vertexes.Add(new LwPolylineVertex(v33));
            line6.Vertexes.Add(new LwPolylineVertex(v34));
            line6.Vertexes.Add(new LwPolylineVertex(v35));
            line6.Vertexes.Add(new LwPolylineVertex(v36));
            line6.Vertexes.Add(new LwPolylineVertex(v37));
            line6.Vertexes.Add(new LwPolylineVertex(v38));
            line6.Vertexes.Add(new LwPolylineVertex(v24));
            fun.PolyFill(dxf, line6, 0.5, contour);

            LwPolyline line7 = new LwPolyline();
            line7.Vertexes.Add(new LwPolylineVertex(v26));
            line7.Vertexes.Add(new LwPolylineVertex(v24));
            line7.Vertexes.Add(new LwPolylineVertex(v39));
            line7.Vertexes.Add(new LwPolylineVertex(v37));
            fun.PolyFill(dxf, line7, 0.5, contour);

            fun.drawcircle(dxf, v47, l3 / 10.564, 0.5, contour);

            //3
            LwPolyline line8 = new LwPolyline();
            line8.Vertexes.Add(new LwPolylineVertex(v54));
            line8.Vertexes.Add(new LwPolylineVertex(v52));
            line8.Vertexes.Add(new LwPolylineVertex(v53));
            line8.Vertexes.Add(new LwPolylineVertex(v48));
            line8.Vertexes.Add(new LwPolylineVertex(v49));
            line8.Vertexes.Add(new LwPolylineVertex(v50));
            line8.Vertexes.Add(new LwPolylineVertex(v56));
            line8.Vertexes.Add(new LwPolylineVertex(v55));
            line8.Vertexes.Add(new LwPolylineVertex(v59));
            line8.Vertexes.Add(new LwPolylineVertex(v60));
            line8.Vertexes.Add(new LwPolylineVertex(v58));
            line8.Vertexes.Add(new LwPolylineVertex(v57));
            fun.PolyFill(dxf, line8, 0.5, contour);

            LwPolyline line9 = new LwPolyline();
            line9.Vertexes.Add(new LwPolylineVertex(v61));
            line9.Vertexes.Add(new LwPolylineVertex(v62));
            fun.PolyFill(dxf, line9, 0.5, contour);


            //4
            LwPolyline line10 = new LwPolyline();
            line10.Vertexes.Add(new LwPolylineVertex(v84));
            line10.Vertexes.Add(new LwPolylineVertex(v65));
            line10.Vertexes.Add(new LwPolylineVertex(v64));
            line10.Vertexes.Add(new LwPolylineVertex(v63));
            line10.Vertexes.Add(new LwPolylineVertex(v81));
            line10.Vertexes.Add(new LwPolylineVertex(v82));
            line10.Vertexes.Add(new LwPolylineVertex(v83));
            line10.Vertexes.Add(new LwPolylineVertex(v87));
            fun.PolyFill(dxf, line10, 0.5, contour);

            LwPolyline line11 = new LwPolyline();
            line11.Vertexes.Add(new LwPolylineVertex(v66));
            line11.Vertexes.Add(new LwPolylineVertex(v85));
            line11.Vertexes.Add(new LwPolylineVertex(v67));
            line11.Vertexes.Add(new LwPolylineVertex(v68));
            line11.Vertexes.Add(new LwPolylineVertex(v69));
            line11.Vertexes.Add(new LwPolylineVertex(v70));
            line11.Vertexes.Add(new LwPolylineVertex(v71));
            line11.Vertexes.Add(new LwPolylineVertex(v72));
            line11.Vertexes.Add(new LwPolylineVertex(v73));
            line11.Vertexes.Add(new LwPolylineVertex(v74));
            line11.Vertexes.Add(new LwPolylineVertex(v75));
            line11.Vertexes.Add(new LwPolylineVertex(v76));
            line11.Vertexes.Add(new LwPolylineVertex(v77));
            line11.Vertexes.Add(new LwPolylineVertex(v78));
            line11.Vertexes.Add(new LwPolylineVertex(v79));
            line11.Vertexes.Add(new LwPolylineVertex(v66));
            fun.PolyFill(dxf, line11, 0.5, contour);

            LwPolyline line12 = new LwPolyline();
            line12.Vertexes.Add(new LwPolylineVertex(v67));
            line12.Vertexes.Add(new LwPolylineVertex(v66));
            line12.Vertexes.Add(new LwPolylineVertex(v80));
            line12.Vertexes.Add(new LwPolylineVertex(v78));
            fun.PolyFill(dxf, line12, 0.5, contour);

            fun.drawcircle(dxf, v86, l3 / 10.564, 0.5, contour);

            //5
            LwPolyline line13 = new LwPolyline();
            line13.Vertexes.Add(new LwPolylineVertex(v89));
            line13.Vertexes.Add(new LwPolylineVertex(v90));
            line13.Vertexes.Add(new LwPolylineVertex(v91));
            line13.Vertexes.Add(new LwPolylineVertex(v92));
            line13.Vertexes.Add(new LwPolylineVertex(v93));
            line13.Vertexes.Add(new LwPolylineVertex(v94));
            line13.Vertexes.Add(new LwPolylineVertex(v95));
            line13.Vertexes.Add(new LwPolylineVertex(v88));
            line13.Vertexes.Add(new LwPolylineVertex(v89));
            line13.Vertexes[0].Bulge = Math.Tan(97 * pi / 180 / 4);
            line13.Vertexes[1].Bulge = Math.Tan(-81 * pi / 180 / 4);
            line13.Vertexes[2].Bulge = Math.Tan(82 * pi / 180 / 4);
            line13.Vertexes[3].Bulge = Math.Tan(-70 * pi / 180 / 4);
            line13.Vertexes[4].Bulge = Math.Tan(77 * pi / 180 / 4);
            line13.Vertexes[5].Bulge = Math.Tan(-98 * pi / 180 / 4);
            fun.PolyFill(dxf, line13, 0.5, contour);

            LwPolyline line14 = new LwPolyline();
            line14.Vertexes.Add(new LwPolylineVertex(v96));
            line14.Vertexes.Add(new LwPolylineVertex(v97));
            line14.Vertexes.Add(new LwPolylineVertex(v98));
            line14.Vertexes.Add(new LwPolylineVertex(v99));
            line14.Vertexes.Add(new LwPolylineVertex(v100));
            line14.Vertexes.Add(new LwPolylineVertex(v101));
            line14.Vertexes.Add(new LwPolylineVertex(v102));
            line14.Vertexes.Add(new LwPolylineVertex(v103));
            fun.PolyFill(dxf, line14, 0.5, contour);

            Line line15 = new Line(v104, v105);
            line15.Layer = centre;
            line15.Linetype = Linetype.DashDot;
            line15.LinetypeScale = 3;
            dxf.AddEntity(line15);

            Line line16 = new Line(v106, v105);
            line16.Layer = centre;
            line16.Linetype = Linetype.DashDot;
            line16.LinetypeScale = 3;
            dxf.AddEntity(line16);

            Line line17 = new Line(v106, v107);
            line17.Layer = centre;
            line17.Linetype = Linetype.DashDot;
            line17.LinetypeScale = 3;
            dxf.AddEntity(line17);

            Line line18 = new Line(v104, v107);
            line18.Layer = centre;
            line18.Linetype = Linetype.DashDot;
            line18.LinetypeScale = 3;
            dxf.AddEntity(line18);

            //6
            LwPolyline line19 = new LwPolyline();
            line19.Vertexes.Add(new LwPolylineVertex(a89));
            line19.Vertexes.Add(new LwPolylineVertex(a90));
            line19.Vertexes.Add(new LwPolylineVertex(a91));
            line19.Vertexes.Add(new LwPolylineVertex(a92));
            line19.Vertexes.Add(new LwPolylineVertex(a93));
            line19.Vertexes.Add(new LwPolylineVertex(a94));
            line19.Vertexes.Add(new LwPolylineVertex(a95));
            line19.Vertexes.Add(new LwPolylineVertex(a88));
            line19.Vertexes.Add(new LwPolylineVertex(a89));
            line19.Vertexes[0].Bulge = Math.Tan(97 * pi / 180 / 4);
            line19.Vertexes[1].Bulge = Math.Tan(-81 * pi / 180 / 4);
            line19.Vertexes[2].Bulge = Math.Tan(82 * pi / 180 / 4);
            line19.Vertexes[3].Bulge = Math.Tan(-70 * pi / 180 / 4);
            line19.Vertexes[4].Bulge = Math.Tan(77 * pi / 180 / 4);
            line19.Vertexes[4].Bulge = Math.Tan(-98 * pi / 180 / 4);
            fun.PolyFill(dxf, line19, 0.5, contour);

            LwPolyline line20 = new LwPolyline();
            line20.Vertexes.Add(new LwPolylineVertex(a96));
            line20.Vertexes.Add(new LwPolylineVertex(a97));
            line20.Vertexes.Add(new LwPolylineVertex(a98));
            line20.Vertexes.Add(new LwPolylineVertex(a99));
            line20.Vertexes.Add(new LwPolylineVertex(a100));
            line20.Vertexes.Add(new LwPolylineVertex(a101));
            line20.Vertexes.Add(new LwPolylineVertex(a102));
            line20.Vertexes.Add(new LwPolylineVertex(a103));
            fun.PolyFill(dxf, line20, 0.5, contour);

            Line line21 = new Line(a104, a105);
            line21.Layer = centre;
            line21.Linetype = Linetype.DashDot;
            line21.LinetypeScale = 3;
            dxf.AddEntity(line21);

            Line line22 = new Line(a106, a105);
            line22.Layer = centre;
            line22.Linetype = Linetype.DashDot;
            line22.LinetypeScale = 3;
            dxf.AddEntity(line22);

            Line line23 = new Line(a106, a107);
            line23.Layer = centre;
            line23.Linetype = Linetype.DashDot;
            line23.LinetypeScale = 3;
            dxf.AddEntity(line23);

            Line line24 = new Line(a104, a107);
            line24.Layer = centre;
            line24.Linetype = Linetype.DashDot;
            line24.LinetypeScale = 3;
            dxf.AddEntity(line24);

            //坐标系
            fun.Axis(dxf, v3, 90, 180, "Y", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a1, 90, 180, "Y", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a2, 90, 180, "Z", "Y", "", 1, 2, 0);

            fun.Axis(dxf, v45, -90, 180, "X", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a3, 90, 180, "X", "Y", "", 1, 2, 0);

            fun.Axis(dxf, v47, -90, 180, "X", "Y", "", 1, 2, 0);

            fun.Axis(dxf, v53, 90, 180, "Y", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a4, 90, 180, "Y", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a5, 90, 180, "Z", "Y", "", 1, 2, 0);

            fun.Axis(dxf, v63, -90, 180, "X", "Z", "", 1, 2, 0);

            fun.Axis(dxf, a6, 90, 180, "X", "Y", "", 1, 2, 0);

            fun.Axis(dxf, v86, -90, 180, "X", "Y", "", 1, 2, 0);



            //标注

            double height = 2;
            double arrowsize = 2;
            double exline = 2;



            //1
            fun.dimrot1(dxf, v1, v7, 0, oal / 3, 1, height, arrowsize, exline, "LPR,LTA", "", "");

            //2
            fun.dimrot1(dxf, v21, v40, 90, l3 / 2, 1, height, arrowsize, exline, "DCONMS", "", "");

            fun.dimrot1(dxf, v40, v24, 180, l3, 1, height, arrowsize, exline, "OAL,LF", "", "");

            fun.dimrot1(dxf, v24, v20, -90, l3 / 2, 1, height, arrowsize, exline, "WF,WTA", "", "");

            fun.drawcircle(dxf, v39, l3 / 2.402, 0.5, dimensioning);

            //3
            fun.dimrot1(dxf, v48, v53, 90, l3 / 2, 1, height, arrowsize, exline, "H", "", "");

            fun.dimrot1(dxf, a4, v49, 0, oal / 3 - h / 2, 1, height, arrowsize, exline, "LPR,LTA", "", "");

            fun.dimrot1(dxf, v52, v49, -90, l3 * 2, 1, height, arrowsize, exline, "HF", "", "");

            //4
            fun.dimrot1(dxf, v63, v81, 90, l3 / 2, 1, height, arrowsize, exline, "B", "", "");

            fun.dimrot1(dxf, v64, a7, 90, oal / 2, 1, height, arrowsize, exline, "=", "", "");

            fun.dimrot1(dxf, v82, a7, 90, oal / 2 - (v64.X +a7.X )/2+(v82.X+a7.X)/2, 1, height, arrowsize, exline, "=", "", "");

            fun.dimrot1(dxf, v66, a7, -90, l3 * 2, 1, height, arrowsize, exline, "WTA", "", "");

            fun.dimrot1(dxf, v66, v64, -90, l3 * 3, 1, height, arrowsize, exline, "WF", "", "");

            fun.dimrot1(dxf, v81, v66, 180, l3, 1, height, arrowsize, exline, "OAL,LF", "", "");

            fun.drawcircle(dxf, v80, l3 / 2.402, 0.5, dimensioning);

            //5
            fun.dimrot1(dxf, v98, v88, 180, dconms, 1, height, arrowsize, exline, "PDY", "", "");

            fun.dimrot1(dxf, v98, v88, -90, dconms, 1, height, arrowsize, exline, "PDX", "", "");

            //6
            fun.dimrot1(dxf, a98, a88, 180, dconms, 1, height, arrowsize, exline, "PDY", "", "");

            fun.dimrot1(dxf, a98, a88, -90, dconms, 1, height, arrowsize, exline, "PDX", "", "");













            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

    }
}
